顺时针打印矩阵
class Solution {
public:
    vector<int> printMatrix(vector<vector<int> > matrix) {
        vector<int> v;
        //行
        int sow=matrix.size();
        //列
        int col=matrix[0].size();
        int up=0;
        int down=sow-1;
        int left=0;
        int right=col-1;
        while(1)
        {
            //从左到右
            if(left<=right)
            {
                for(int i=left;i<=right;i++)
                {
                    v.push_back(matrix[up][i]);
                }
                up++;
            }
            if(up>down)
                break;
            //从上到下
            if(up<=down)
            {
                for(int i=up;i<=down;i++)
                {
                    v.push_back(matrix[i][right]);
                }
                right--;
            }
            if(left>right)
                break;
            //从右到左
            if(right>=left)
            {
                for(int i=right;i>=left;i--)
                {
                    v.push_back(matrix[down][i]);
                }
                down--;
            }
            if(up>down)
                break;
            //从下到上
            if(down>=up)
            {
                for(int i=down;i>=up;i--)
                {
                    v.push_back(matrix[i][left]);
                }
                left++;
            }
            if(left>right)
                break;
        }
        return v;
    }
};